package cn.gson.boot.model.dao;

import cn.gson.boot.model.pojos.Productt;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import javax.transaction.Transactional;

public interface ProducttDao extends CrudRepository<Productt,Integer> {

    /*修改产品的库存数量*/
    //入库
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(nativeQuery = true,value = "update productt_  set productt_inventory = productt_inventory + ?1 where productt_id=?2")
    public void updateRuKuProductKuCun(Integer proNum,Integer producttId);

    /*修改产品的库存数量*/
    //出库
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(nativeQuery = true,value = "update productt_  set productt_inventory = productt_inventory - ?1 where productt_id=?2")
    public void updateChuKuProductKuCun(Integer proNum,Integer producttId);
}
